<?php
namespace app\api\controller\v1;

use app\api\model\Ticket as TicketModel;
use app\api\service\TokenService;
use app\api\validate\TicketValidate ;
use app\lib\exception\BaseException;
use app\lib\exception\SuccessMessage;

//用户地址类
class Ticket extends Base
{
    //TP5的前置方法
    protected $beforeActionList = [
        //'checkScope' => ['only' => 'createOrUpdateAddress']
        'checkScope'
    ];

    //编辑机票信息
    public function upload_ticket(){
        $validate = new TicketValidate();
        $validate->goCheck();
        $post = $validate->getDataByRule(input('post.'));
        $post['depart_time'] = $post['depart_date'].' '.$post['depart_time'];
        $post['return_time'] = $post['return_date'].' '.$post['return_time'];
        unset($post['depart_date']);
        unset($post['return_date']);
        $uid = TokenService::getCurrentUid();//接收token，获取uid
        return TicketModel::CreateOne($uid,$post);
    }

    //获取机票信息
    public function ticket_info(){
        $uid = TokenService::getCurrentUid();//接收token，获取uid
        return TicketModel::GetInfo($uid);
    }

    //删除机票信息
    public function del_ticket($type){
        if($type == '1'){
            $uid=TokenService::getCurrentUid();
            return TicketModel::ticket_all_del($uid);
        }
    }

}
